package com.dodayum.config;

import com.dodayum.MyJob;
import org.quartz.*;
import org.springframework.context.annotation.Bean;

//@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail jobDetail() {
        return JobBuilder
                .newJob(MyJob.class)
                .storeDurably() // 开启持久化
                .withIdentity("job1", "group1") // 唯一标识
                .usingJobData("count", 1) // 共享数据初始化
                .build();
    }

    @Bean
    public Trigger trigger() {
        return TriggerBuilder
                .newTrigger()
                .forJob(jobDetail()) // 进行关联
                .withIdentity("trigger1", "group1") // 唯一标识
                .withSchedule(CronScheduleBuilder.cronSchedule("0/3 * * * * ? ")) // 时间规则
                .build();
    }

}
